package com.fh.practice.commons;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Component // 将当前类交给ioc管理
public class KuayuInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {

        // 处理跨域的  response设置运行跨域
        // 获取请求域
        String origin = request.getHeader("Origin");

            response.setHeader("Access-Control-Allow-Origin",origin);
        return true;
    }
}
